const app = getApp();
var config = app.globalData.config;
const http = require('../../utils/http.js');
Page({
  data: {
    indicatorDots: true,
		vertical: false,
		autoplay: false,
		interval: 2000,
    duration: 500,
    
    monthTime: "", //月
		dayTime: "", //月
		weekTime: "", //星期
		msgCount: 0, //消息数量
		todayList: [], //今日课程数据
    myList: [], //我的课程数据
    
    userInfo:[],
    group_id:1
  },
  onLoad(options) {
    this.getNowTime();
		this.getMsgCount(); //获取消息总数
		this.getTodayCourse();
		this.getMyCourse();
  },
  onReady() {
    if (!app.login()) {
			return;
		}
    let userInfo = app.globalData.userInfo;
    let group_id = userInfo.group_id;
    this.setData({
      userInfo:userInfo,
      group_id:group_id
    })
  },
  goUrl(e){//跳转链接
    var _url = e.currentTarget.dataset.turl;
    wx.navigateTo({
      url: _url,
    })
  },
  //教师端
  getNowTime() { //获取当前时间
		var _month = new Date().getMonth() + 1;
		var _day = new Date().getDate();

		var show_day = new Array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
		var date = new Date();
		date.setDate(date.getDate());
		var dayFun = date.getDay();
		var _weekTime = show_day[dayFun];
    console.log(_weekTime);
		this.setData({
			monthTime: _month,
			dayTime: _day,
			weekTime: _weekTime
		});
  },
  getMsgCount() { //获取消息总数
		var that = this;
		http.httpPost(config.getMessageCount, {}, function(e) {
			// console.log(e);
			that.setData({
				'msgCount': e.data
			});
		});
  },
  getTodayCourse() { //获取今日课程
		var that = this;
		http.httpPost(config.getTodayCourse, {
      is_curriculum:true
    }, function(e) {
			that.setData({
				'todayList': e.data
			});
		});
  },
  getMyCourse() { //获取我的课程
		var that = this;
		http.httpPost(config.getMyCourse, {}, function(e) {
			// console.log(e);
			that.setData({
				'myList': e.data
			});
		});

	},
  developmentFun(){
		wx.showToast({
			title: "开发中",
			icon: 'none',
			duration: 1000,
			mask: true
		});
	},
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})